:::note
This tutorial assumes that you have already set up your development environment
as described in the [Getting Started](/getting-started/installing/) guide.
:::

#### Create a new Git Repository

We start by creating a new git repository for our project. If you have never worked with git before, you can find a good introduction [here](https://git-scm.com/book/en/v2/Getting-Started-About-Version-Control) or [here](https://docs.github.com/en/get-started/getting-started-with-git/set-up-git).

Let's create a new directory for our project in which we will store our code. We will call this directory `hello_world`.

```bash
mkdir hello_world && cd hello_world
```

Next, we initialize a new git repository in this directory. This will allow us to track changes to our code and collaborate with others and also allows us to easily get RIOT as a submodule.

```bash
git init
```

![The output of the git init command](img/gitsetup/01_empty_git.png)

Congratulations! You have now created a new empty git repository. In the next step, we will add RIOT as a submodule to our project.

#### Add RIOT as a Submodule

We want to import RIOT as a submodule to our project. This will allow us to easily update to newer versions of RIOT and also allows us to easily share our project with others on GitHub, Gitlab, or any other git hosting service.

To add RIOT as a submodule, we use the following command:

```bash
git submodule add https://github.com/RIOT-OS/RIOT.git
```

![Adding the submodule](img/gitsetup/02_riot_submodule.png)

When looking into our directory via `ls`, we can see that a new directory called `RIOT` has been created. This directory contains the RIOT source code. If you were to push your project to a git hosting service, the `RIOT` directory would not be included in the repository. Instead, the repository would contain a reference to the commit of the RIOT repository that you have added as a submodule. This way, the repository stays small and only contains the code that you have written and not the entire RIOT source code.

:::note
Remember that you need to clone your own repository with the `--recursive` option to get the submodule as well.

```bash
git clone --recursive https://git.example.com/your/repo.git
```

Alternatively if you have already cloned your own repository, you can run the following command to initialize and update the submodule:

```bash
git submodule update --init --recursive
```
:::
